package com.kaiwukj.android.ufamily.mvp.ui.adapter;

import com.blankj.utilcode.util.StringUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kaiwukj.android.ufamily.R;
import com.kaiwukj.android.ufamily.mvp.http.entity.resultbak.PayFeeResult;

import java.util.ArrayList;

/**
 * Created by Administrator on 2019/10/25
 */
public class PayFeeHistoryAdapter extends BaseQuickAdapter<PayFeeResult, BaseViewHolder> {
    public PayFeeHistoryAdapter() {
        super(R.layout.item_payfee_history, new ArrayList<>());
    }


    public void clear() {
        getData().clear();
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, PayFeeResult item) {
        String name;
        if (item.getType() == 1) {
            name = "物业费";
        } else if (item.getType() == 2 || item.getType() == 3) {
            name = "车位费";
        } else {
            name = "未知";
        }
        helper.setText(R.id.tv_name, name);

        if (!StringUtils.isEmpty(item.getPayTime())) {
            helper.setText(R.id.tv_time, TimeUtils.getFriendlyTimeSpanByNow(item.getPayTime()));
        } else {
            helper.setText(R.id.tv_time, "未知时间!");
        }

        helper.setText(R.id.tv_monty, String.valueOf(item.getPaymentAmount()));

    }
}
